var submitShareObj = {
    el: '#pageApp',
    data: {
      userMsg:{},
      shareTitle:'',
      shareCateVal:3,
      privateMeVal:false,
      contactWay:'',
      remark:'',
      imgList:[],
      uploadImgList:[]
    },
    components:{
     
    },
    methods: {
      getUserinfo:function(){
       this.userMsg = g.storage.getUser();
      },
      checkShareCate:function(val){
        this.shareCateVal = val;
      },
      toggleSwitch:function(){
        this.privateMeVal = !this.privateMeVal;
      },
      uploadImg:function(){
        var _this = this;
        $.imgUpload({
          progressCallBack:function (curr) {
        
          },
          successCallback:function(path){
            _this.uploadImgList.push(path);
            _this.imgList.push(g.url.imgFormat(path));
          },
          cropper:false,
          cropperOpts: {
            aspectRatio: 1 / 1,
            preview:$('.cropper-preview'),
            zoomable:false,
            viewMode:1, 
          }
        },cos);
      },
      submitShare:function(){
        var _this = this;
        this.setPostData();
      },
      setPostData:function(){
         var data = {};
         data.articleid = 0;
         data.author = this.userMsg.nickname;
         data.authorImg = this.userMsg.img;
         if(!this.shareTitle){
           g.modal.tip({title:'请输入标题！'});
           return;
         };
         data.title = this.shareTitle;
         data.categoryId = this.shareCateVal;
         if(data.categoryId == 3){
          data.categoryName = '生活服务';
         }
         if(data.categoryId == 4){
          data.categoryName = '物有所用';
         }
         data.content = this.remark;
         if(!this.remark){
           g.modal.tip({title:'请填写备注信息！'});
           return;
         };
         data.description = this.remark;
         data.phone = this.contactWay;
         data.isPrivate = this.privateMeVal?1:0;
         data.img = this.uploadImgList.join(',');
         this.postData(data); 
      },
      postData:function(data){
          g.modal.waiting({title:"发布中",icon:'icon-jiazaizhong-copy',wait:true});
          g.ajax({
          type: 'POST',
          url: g.url.format('/api/author/addArticle'),
          data:data,
          success: function (result) {
             history.go(-1);
          }
        });
      }
    },
    mounted:function () {
      this.getUserinfo();
    }
};
var initPage = function(){
  new Vue(submitShareObj);
};